package com.example.nextstream.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.nextstream.mapper.AssetsInfoMapper;
import com.example.nextstream.models.AssetsInfo;
import com.example.nextstream.models.User;
import com.example.nextstream.service.AssetsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("assetsInfoService")
public class AssetsInfoServiceImpl extends ServiceImpl<AssetsInfoMapper, AssetsInfo> implements AssetsInfoService {


    @Override
    public Boolean createAssets(AssetsInfo assetsInfo){
        baseMapper.insert(assetsInfo);
        return true;
    }
    @Override
    public Boolean deleteAssets(Integer assetsId){
        baseMapper.deleteById(assetsId);
        return  true;
    }
    @Override
    public AssetsInfo getAssets(Integer id){
        return baseMapper.selectById(id);
    }
    @Override
    public Page<AssetsInfo> listAssetsInfo( int pageNum,int pageSize){
        Page<AssetsInfo> page= new Page<>(pageNum,pageSize);
        return baseMapper.selectPage(page,null);
        //return res;
    }

    @Override
    public Boolean updateAssets(AssetsInfo assetsInfo) {
        baseMapper.updateById(assetsInfo);
        return  true;
    }

    @Override
    public Integer countAssets() {
        return baseMapper.selectCountAssets();
    }
}
